package com.scnlf.scnlf.portal.core.common.config;

import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.domain.AuditorAware;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;

@Configuration
@EnableJpaAuditing
@EntityScan(basePackages = {
    "com.scnlf.scnlf.portal.core.business.event.entity",
    "com.scnlf.scnlf.portal.core.business.sys.entity",
    "com.scnlf.scnlf.portal.core.business.loan.entity",
    "com.scnlf.scnlf.portal.core.business.trade.entity"
})
@EnableJpaRepositories(basePackages = {
    "com.scnlf.scnlf.portal.core.business.event.repo",
    "com.scnlf.scnlf.portal.core.business.sys.repo",
    "com.scnlf.scnlf.portal.core.business.loan.repo",
    "com.scnlf.scnlf.portal.core.business.trade.repo"})
public class JpaConfig {

  @Bean
  @ConditionalOnMissingBean(AuditorAware.class)
  public AuditorAware<String> anonymousAuditorAware() {
    return new DefaultAuditorAware();
  }

}
